<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>字典管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/dtree.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/dtree/font/iconfont.css"/>
</head>

<body class="childrenBody">
<form class="layui-form"><input type="hidden" id="id" name="id" value="${sysRole.id}"/>
    <div class="layui-form-item layui-row layui-col-xs12"><label class="layui-form-label"><span class="red">*</span>&nbsp;&nbsp;角色名称</label>
        <div class="layui-input-block"><input type="text" class="layui-input" name="roleName"
                                              value="${sysRole.roleName}" placeholder="请输入角色名称" lay-verify="required"
                                              autocomplete="off"/></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12"><label class="layui-form-label"><span class="red">*</span>&nbsp;&nbsp;排序</label>
        <div class="layui-input-block"><input type="text" class="layui-input" name="sort" value="${sysRole.sort}"
                                              placeholder="请输入排序" lay-verify="required" autocomplete="off"/></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12"><label class="layui-form-label"><span class="red">*</span>&nbsp;&nbsp;状态</label>
        <div class="layui-input-block"><select class="form-control" name="status" lay-verify="required"
                                               id="status"></select></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label"><span class="red">*</span>&nbsp;&nbsp;菜单</label>
        <div class="layui-input-block">
            <!--树开始-->
            <div class="cont-dtree dtree-height">
                <ul id="menu" class="dtree" data-id="0" style=""></ul>
            </div>
            <!--树结束-->
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['form', 'jquery', 'baseUtil', 'checkUtil','pageUtil', 'dtreeUtil'], function () {
    var form = layui.form, $ = layui.jquery, baseUtil = layui.baseUtil, pageUtil = layui.pageUtil, dtreeUtil = layui.dtreeUtil, checkUtil = layui.checkUtil;

    var menuIds='${sysRole.menuIds}';
    dtreeUtil.pageDtree("#menu","/sysMenu/dTreeList",true,function (data,obj) {
        if(checkUtil.isNotEmpty(menuIds)){
            dtreeUtil.chooseDataInit("menu",menuIds);
        }
    });

    pageUtil.initDict("base_status", function (dictData) {
        pageUtil.showDict($("#status"), pageUtil.aceeptDictContentList(dictData, "base_status"), "", '${sysRole.status}');
    });
    form.on('submit(submitBtn)', function (data) {
        dtreeUtil.getCheckbarNodesParam("menu",function (params) {
            if(params.length == 0){
                dialog.msg("请至少选择一个权限");
                return false;
            }
            var ids = [];
            for(var key in params){
                var param = params[key];
                ids.push(param.nodeId);
            }
            data.field.menuIds=ids.join(",");
            baseUtil.postMethodResult("/sysRole/addOrUpdate", data.field, function (result) {
                parent.location.reload();
            });
        })

        return false;
    });
});</script>
</body>

</html>